var wxLocalStorage = function () {
    var _getKey = function (key) {
        return "WXYLXZ3269002KEY" + key;
    };
    var _getTimeKey = function (key) {
        return "WXYLXZ3269002TIME" + key;
    };
    var _del = function (key) {
        var timeKey = _getTimeKey(key);
        var valKey = _getKey(key);
        localStorage.removeItem(timeKey);
        localStorage.removeItem(valKey);
        return true;
    };
    /**
     * 删除
     * @param key
     */
    this.del = function (key) {
        return _del(key);
    };
    /**
     * 获取
     * @param key
     */
    this.get = function (key) {
        if (!_checkOverTime(key)) {
            return 0;
        }
        var valKey = _getKey(key);
        return localStorage.getItem(valKey);
    };

    /**
     * 保存数据
     * @param key
     * @param val
     * @param expire 单位S 60,存储60秒
     */
    this.set = function (key, val, expire) {
        if (expire < 0) {
            return 0;
        }
        var saveTime = Date.parse(new Date()) + expire * 1000;
        var timeKey = _getTimeKey(key);
        var valKey = _getKey(key);
        localStorage.setItem(timeKey, saveTime);
        localStorage.setItem(valKey, val);
        return true;
    };

    /**
     * 检测有没有超时
     * @private
     */
    var _checkOverTime = function (key) {
        var timeKey = _getTimeKey(key);
        var saveTime = parseInt(localStorage.getItem(timeKey));
        var nowStamp = Date.parse(new Date());
        if (saveTime < nowStamp) {
            _del(key);
            return false;
        }
        return true;
    };
};